home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / ask3.zip / ASK3EG.BAT < prev    next >
DOS Batch File  |  1986-12-11  |  3KB  |  105 lines

  1. echo off
  2. :home
  3. echo.
  4. echo This is a batch file to demonstrate how to use ASK.
  5.  
  6. rem *** EXAMPLE #1
  7. echo -----------------------------------------------------------------------
  8. echo First, a trival example:
  9. ask "Hit a key when ready .."
  10.  
  11. rem *** EXAMPLE #2
  12. echo -----------------------------------------------------------------------
  13. echo Now, a simple example:
  14. ask "Is there a cat in your house (press Y or N)? " yn
  15. if errorlevel 2 goto dont
  16. echo Good! Some day I'll have to come visit your cat.
  17. goto eg3
  18. :dont
  19. echo You don't? If you like, you can come visit the cat in my house.
  20.  
  21. rem *** EXAMPLE #3
  22. :eg3
  23. echo -----------------------------------------------------------------------
  24. echo You can create a menu with ASK:
  25. echo [F1]   Hamburger
  26. echo [F2]   Chicken Haha King
  27. echo [F3]   Toss Salad
  28. echo.
  29. ask "May I take your order? " ~(f1)~(f2)~(f3)
  30. if errorlevel 3 goto toss
  31. if errorlevel 2 goto chicken
  32. echo Here's your Hamburger. Enjoy your sandwitch.
  33. goto eg4
  34. :chicken
  35. echo Here's your Chicken Haha King. Ha ha.
  36. goto eg4
  37. :toss
  38. echo Your salad is tossed.
  39.  
  40. :eg4
  41. echo -----------------------------------------------------------------------
  42. echo Now an advance example showing the timeout feature:
  43. echo Suppose there's a time bomb in this batch file and and is set to go
  44. echo off in 10 seconds, and you have the following choices:
  45. echo R) Run
  46. echo r) Reboot
  47. echo T) Try to disarm it
  48. rem *** make response case sensitive to make it harder
  49. ask/fcs10 "What would you do (press R/r/T)? " RrT
  50. if errorlevel 255 goto bomb
  51. if errorlevel 3 goto disarm
  52. if errorlevel 2 goto boot
  53.  
  54. rem *** run. Note the use of ask with timeout=0 (default) as an echo command.
  55. rem *** You can echo control characters this way.
  56. echo Running...
  57. ask/s "\7You had run ten feet when the bomb exploded.~m~j"
  58. echo Now you're at 100 feet!
  59. goto folks
  60.  
  61. :boot
  62. echo That would have worked, but you should use ctrl-alt-del to reboot.
  63. echo Anyway, you got blasted.
  64. goto folks
  65.  
  66. :disarm
  67. echo Disarming...
  68. echo You succeeded in disarming the bomb. Congratulation.
  69. goto folks
  70.  
  71. :bomb
  72. echo *CLICK*      ! ! ! B O O M ! ! !
  73. rem *** use ask to print control characters (bells in this case)
  74. ask/s \7\7\7
  75. echo You're too slow. The timer made a home run and you're out.
  76. goto folks
  77.  
  78. :folks
  79. echo -----------------------------------------------------------------------
  80. rem *** do ansi.sys demo
  81. ask/fs0 \e[6n~m
  82. if errorlevel 27 goto ansi
  83. echo If you have installed the ANSI.SYS driver I can show you how to
  84. echo change screen attribute with ASK. But you don't. Oh well.
  85. goto nomore
  86. :ansi
  87. ask/fs "You can use ASK to change screen attributes:~m~j"
  88. ask/s "\e[5mBlink \e[7mReverse video \e[32mColor maybe? \e[0m~m~j"
  89.  
  90. :nomore
  91. echo That's the end of the ASK demo.
  92. rem *** actually not, this is another one.
  93. rem *** show the no echo option
  94. echo If you want to run this demo again, press the (Home) key; otherwise
  95. ask/eq "press the (End) key to return to DOS." ~(end)~(home)
  96. :loop
  97. if errorlevel 2 goto home
  98. if errorlevel 1 goto dos
  99. ask/eq "\7" ~(end)~(home)
  100. goto loop
  101.  
  102. :dos
  103. echo.
  104.  
  105.